using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AdminApiTemplate.Common.Exceptions
{
    /// <summary>
    /// 带错误编码的异常
    /// </summary>
    public class WithCodeException : Exception
    {
        /// <summary>
        /// 错误编码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 错误信息（内部调试用）
        /// </summary>
        public string Message2 { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">错误编码</param>
        /// <param name="msg">错误信息（外部显示用）</param>
        public WithCodeException(int code, string msg) : base(msg)
        {
            Code = code;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">错误编码</param>
        /// <param name="msg">错误信息（外部显示用）</param>
        /// <param name="msg2">错误信息（内部调试用）</param>
        public WithCodeException(int code, string msg, string msg2) : base(msg)
        {
            Code = code;
            Message2 = msg2;
        }
    }

    /// <summary>
    /// 错误编码
    /// </summary>
    public enum ErrorCodeEnum
    {
        /// <summary>
        /// 参数错误
        /// </summary>
        InvalidArguments = 1,

        /// <summary>
        /// 代码错误
        /// </summary>
        CodeError = 3,

        /// <summary>
        /// 没有权限
        /// </summary>
        NotAllowed = 401,

        /// <summary>
        /// 未知错误
        /// </summary>
        Unknown = 999
    }
}
